$(document).ready(function (){
	$('#school_pList').click( function() {
		$('#school_cList').html('');
		var str='';
		for (var i=0; i<this.options.length; i++){
  			if (this.options[i].selected){
  				if (this.options[i].value!=0){
	  				str+=this.options[i].value;
	  				str+=','
  				}
  			}
		}
		$('#school_pList').attr('disabled',true);
		$('#school_cList').attr('disabled',true);
		if (str.length>0){
			$.ajax({
			 type: "POST",
			 url: "./?ctrl=schooltypes&action=getCtypes",
			 data:   "pids="+str.substr(0,str.length-1),
			 success: function(msg){
			 	var clist=eval(msg);
			 	for (var i=0 ; i < clist.length ;i++){
			 		$('#school_cList').append('<option value="'+clist[i]['id']+'">['+$("option[@value="+clist[i]['pid']+"]").html()+']'+clist[i]['title']+'</option>');
			 	}
			 	$('#school_pList').attr('disabled',false);
			 	$('#school_cList').attr('disabled',false);
			 } 
			}); 
		}
	});
	$('#postform').submit(function(){
		var schooltype_one_ids_hidden_str='';
		$('#school_pList option[@selected]').each(function(i){
			schooltype_one_ids_hidden_str+=this.value;
			schooltype_one_ids_hidden_str+=',';
		});
		$('#schooltype_one_ids_hidden').val(schooltype_one_ids_hidden_str.substr(0,schooltype_one_ids_hidden_str.length-1));
		if ($('#schooltype_one_ids_hidden').val()==''){
			alert("请选择分类一!");
			return false;
		}
		//alert($('#schooltype_one_ids_hidden').val());
		
		var schooltype_two_ids_hidden_str='';
		$('#school_cList option[@selected]').each(function(i){
			schooltype_two_ids_hidden_str += this.value;
			schooltype_two_ids_hidden_str +=',';
			
		});
		$('#schooltype_two_ids_hidden').val(schooltype_two_ids_hidden_str.substr(0,schooltype_two_ids_hidden_str.length-1));
		//alert($('#schooltype_two_ids_hidden').val());
		if ($('#schooltype_two_ids_hidden').val()==''){
			alert("请选择分类二!");
			return false;
		}
		var citys_hidden_hidden_str='';
		$('#citys option[@selected]').each(function(i){
			citys_hidden_hidden_str += this.value;
			citys_hidden_hidden_str +=',';
			
		});
		$('#citys_hidden').val(citys_hidden_hidden_str.substr(0,citys_hidden_hidden_str.length-1));
		if ($('#citys_hidden').val()==''){
			alert("请选择城市!");
			return false;
		}
		var theform=document.getElementById('postform');
		var message = bbinsert && wysiwyg ? html2bbcode(getEditorContents()) : (!theform.parseurloff.checked ? parseurl(theform.message.value) : theform.message.value);
	 	if ( (postminchars != 0 && message.length < postminchars) || (postmaxchars != 0 && message.length > postmaxchars)) {
     		alert("您的帖子长度不符合要求。\n\n当前长度: "+message.length+" 字节\n系统限制: "+postminchars+" 到 "+postmaxchars+" 字节");
   		 	return false;
  		}
   		$('#schoolcontent').val(message) ;
   		if ($('#schoolcontent').val().length<2){
   			//$('#schoolcontent').focus(); 
   			alert("请填写内容");
			return false;	
   		}
   		if ($('#schoolkeyword').val().length<2){
   			alert("请填写正确的关键字");
   			//$('#schoolkeyword').focus(); 
			return false;	
   		}
   		if ($('#schooltitle').val().length<2){
   			alert("请填写完整标题");
   			//$('#schooltitle').focus(); 
			return false;	
   		}
   		if ($('#schoolweburl').val().length<2){
   			alert("请填写网站域名");
   			//$('#schoolweburl').focus(); 
			return false;	
   		}
   		if($('#schoolpricemin').val().length<2){
   			alert("请填写价格1");
   			//$('#schoolpricemin').focus(); 
			return false;	
   		}
   		if($('#schoolpricemax').val().length<2){
   			alert("请填写价格2");
   			//$('#schoolpricemax').focus(); 
			return false;	
   		}
   		if(parseInt($('#schoolpricemin').val())>parseInt($('#schoolpricemax').val())){
   			alert("价格1不能大于价格2");
   			//$('#schoolpricemin').focus(); 
   			return false;
   		}
	});
});

